class User {
  final String id;
  final String name;
  final String? avatarUrl;
  final int coins;
  final List<String> unlockedCharacters;
  final Map<String, List<String>> chatHistory;

  const User({
    required this.id,
    required this.name,
    this.avatarUrl,
    required this.coins,
    required this.unlockedCharacters,
    required this.chatHistory,
  });

  User copyWith({
    String? id,
    String? name,
    String? avatarUrl,
    int? coins,
    List<String>? unlockedCharacters,
    Map<String, List<String>>? chatHistory,
  }) {
    return User(
      id: id ?? this.id,
      name: name ?? this.name,
      avatarUrl: avatarUrl ?? this.avatarUrl,
      coins: coins ?? this.coins,
      unlockedCharacters: unlockedCharacters ?? this.unlockedCharacters,
      chatHistory: chatHistory ?? this.chatHistory,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'name': name,
      'avatarUrl': avatarUrl,
      'coins': coins,
      'unlockedCharacters': unlockedCharacters,
      'chatHistory': chatHistory,
    };
  }

  factory User.fromJson(Map<String, dynamic> json) {
    return User(
      id: json['id'] as String,
      name: json['name'] as String,
      avatarUrl: json['avatarUrl'] as String?,
      coins: json['coins'] as int,
      unlockedCharacters: List<String>.from(json['unlockedCharacters'] as List),
      chatHistory: Map<String, List<String>>.from(
        json['chatHistory'].map(
          (key, value) => MapEntry(
            key,
            List<String>.from(value as List),
          ),
        ),
      ),
    );
  }
} 